{% load comments i18n %}
<form id="cmtform" action="{% comment_form_target %}" method="post">{% csrf_token %}
    {% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
    {% for field in form %}
    {% if field.is_hidden %}
    <div>{{ field }}</div>
    {% else %}
    {% ifequal field.name "comment" %}
    {% if field.errors %}{{ field.errors }}{% endif %}
    <p
    {% if field.errors %} class="error"{% endif %}
    {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
    {{ field.label_tag }} {{ field }}
    </p>
    {% endifequal %}
    {% endif %}
    {% endfor %}

    <input type="hidden" name="next" value="/comments/result/" />
</form>

<p class="submit">
<input id="btnReply" type="button" name="post" class="submit-post" value="回复" />
</p>

<script type="text/javascript">
    $("#btnReply").click(function() {
        $.ajax({
            type: "POST",
            data: $("#cmtform").serialize(),
            url:  "{% comment_form_target %}",
            cache: false,
            dataType: "json",
            success: function(json, textStatus){
                html = '<dt id="c{{ comment.id }}">' + json.posttime + "</dt>";
                html += '<dd><p>' + json.comment + '</p></dd>';
                $("#comments").append(html);
                $("#id_comment").val("");
            }
        })
    })
</script>

